<?php
/**
 * Created by PhpStorm.
 * User: ulric
 * Date: 2016/10/24
 * Time: 14:19
 */

namespace app\components\story\controllers;


use app\components\story\models\StoryForm;
use yii\web\Controller;

class StoryController extends Controller
{
    private $_config = [];
    public function getConfig()
    {
        return $this->_config = (!$this->_config)?$this->loadStory():$this->_config;
    }
    public function actionIndex()
    {
        $model = new StoryForm();
        $model->load($this->config,$this->randLoad());
        return $this->render('@app/components/story/views/index',['model'=>$model]);
    }
    private function loadStory()
    {
        return require_once(__DIR__."/../configs/story.php");
    }
    private function randLoad()
    {
        return array_rand($this->config);
    }
}